package com.xyj.week01;

import java.util.Arrays;

/**
 * 反转数组
 */
public class T9 {


    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5, 6};
        System.out.println(Arrays.toString(nums));
        convertArr(nums);
        System.out.println(Arrays.toString(nums));
    }

    /**
     * 双指针反转数组
     * @param arr 数组
     */
    public static void convertArr(int [] arr){
        int left =0;
        int right= arr.length-1;
        while (left<right){
            int temp = arr[left];
            arr[left]=arr[right];
            arr[right]=temp;
            left++;
            right--;
        }
    }
}
